package main

import "fmt"

type X struct {
	a int
}

type Y struct {
	X
	b int
}

type Z struct {
	Y
	c int
}

func (x X) Print() {
	fmt.Printf("In X,a=%d\n",x.a)
}

func (x X) XPrint(){
	fmt.Printf("In X,a=%d\n",x.a)
}

func (y Y) Print()  {
	fmt.Printf("In Y ,a = %d\n",y.b)
}

func (z Z) Print()  {
	fmt.Printf("In Z ,a = %d\n",z.c)
}

func main() {
	x := X{a:1}

	y := Y{
		X:x,
		b:2,
	}

	z := Z{
		Y:y,
		c:3,
	}

	//从外向内查找print方法，首先调用的是z的print方法
	z.Print()

	z.Y.Print()
}

